package com.example.myapplication;

import android.content.Context;
import android.content.SharedPreferences;

import java.util.HashMap;
import java.util.Map;

public class UserInfo_Pre {
    public static boolean saveUserInfo(String username, String password, Context context){
        SharedPreferences sp=context.getSharedPreferences("MyData",Context.MODE_PRIVATE);
        SharedPreferences.Editor editor=sp.edit();
        editor.putString("username",username);
        editor.putString("password",password);
        editor.commit();
        return true;
    }

    public static Map<String,String> getUserInfo(Context context)
    {
        SharedPreferences sp=context.getSharedPreferences("MyData",Context.MODE_PRIVATE);
        String username=sp.getString("username","");
        String password=sp.getString("password","");
        Map<String,String> map=new HashMap<>();
        map.put("username",username);
        map.put("password",password);
        return map;
    }
}
